#include "encrypt.h"
#include <stdio.h>

#if 0
#ifdef __cplusplus
 extern "C" {
#endif

#include "global.h"
#include "rsa_incl.h"
#include "rsaref.h"
#include "rsa.h"
#include "md5.h"
#include "des.h"
#include "nn.h"
#include "ied.h"

#ifdef __cplusplus
}
#endif

#if 1
void rsa_test(void)
{
  unsigned char publickey[]={
0x00,0x04,0xb5,0x18,0xdf,0xfa,0x9d,0xbd,0x72,0x4d,0x8f,0xde,0xf6,0x26,0x42,0xea,
0x9c,0xa3,0x23,0x79,0xea,0x8e,0x76,0x0d,0x00,0x8f,0x58,0x7f,0x55,0x8b,0x8c,0x95,
0x96,0x02,0x11,0xf9,0xe5,0xae,0x5b,0x5b,0xaf,0x55,0xbd,0x4e,0x88,0xa0,0xcb,0x0a,
0x92,0x5f,0x04,0x8e,0x92,0x74,0x52,0x6a,0xd7,0x33,0x23,0x7a,0x1f,0x6c,0x66,0xc0,
0xc7,0xa9,0xf6,0x98,0x03,0xc7,0xbf,0x2a,0xbe,0x66,0xec,0x43,0x5b,0xda,0x40,0x06,
0x68,0xe4,0x2b,0xab,0x79,0xfc,0x97,0x05,0x20,0xbe,0xae,0x9b,0x1d,0xcf,0x54,0xa5,
0xe9,0x29,0xb2,0x6f,0xb9,0x4d,0x20,0xd8,0x42,0xd0,0xdc,0x4c,0x28,0x8b,0x84,0xe0,
0x8f,0x0f,0xe4,0xe2,0x04,0x3b,0x8c,0x24,0xb9,0x2b,0xdc,0x00,0x3a,0x88,0xd2,0x51,
0x67,0xe9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x01
  };

  unsigned char privatekey[]={

0x00,0x04,0xb5,0x18,0xdf,0xfa,0x9d,0xbd,0x72,0x4d,0x8f,0xde,0xf6,0x26,0x42,0xea,
0x9c,0xa3,0x23,0x79,0xea,0x8e,0x76,0x0d,0x00,0x8f,0x58,0x7f,0x55,0x8b,0x8c,0x95,
0x96,0x02,0x11,0xf9,0xe5,0xae,0x5b,0x5b,0xaf,0x55,0xbd,0x4e,0x88,0xa0,0xcb,0x0a,
0x92,0x5f,0x04,0x8e,0x92,0x74,0x52,0x6a,0xd7,0x33,0x23,0x7a,0x1f,0x6c,0x66,0xc0,
0xc7,0xa9,0xf6,0x98,0x03,0xc7,0xbf,0x2a,0xbe,0x66,0xec,0x43,0x5b,0xda,0x40,0x06,
0x68,0xe4,0x2b,0xab,0x79,0xfc,0x97,0x05,0x20,0xbe,0xae,0x9b,0x1d,0xcf,0x54,0xa5,
0xe9,0x29,0xb2,0x6f,0xb9,0x4d,0x20,0xd8,0x42,0xd0,0xdc,0x4c,0x28,0x8b,0x84,0xe0,
0x8f,0x0f,0xe4,0xe2,0x04,0x3b,0x8c,0x24,0xb9,0x2b,0xdc,0x00,0x3a,0x88,0xd2,0x51,
0x67,0xe9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x01,0x9c,0x28,0x96,0xfa,0xc4,0x8a,0x57,0xc6,0x0a,0x09,0x78,0xb8,0x05,0x7b,
0xc9,0x15,0xe3,0xc1,0x7d,0x40,0xdb,0x0a,0xdb,0x30,0xc0,0x5f,0x0c,0xa5,0x08,0xd4,
0xf4,0x45,0x54,0xba,0xe8,0x13,0x31,0x34,0x1e,0x3d,0x10,0xc0,0x67,0x90,0x3f,0x85,
0x1e,0x32,0x50,0xfb,0x9f,0xce,0x2e,0x43,0x72,0xcd,0xe6,0x09,0xa8,0x8f,0x11,0x0b,
0xab,0x1e,0xb0,0xda,0x8a,0xc5,0x8d,0xcc,0xa9,0xff,0x82,0x59,0x2d,0xaf,0x83,0x6d,
0xe2,0xc3,0x70,0xb2,0xb1,0x47,0x05,0x28,0x96,0x36,0x49,0x03,0x1b,0x98,0xad,0x00,
0x91,0x4d,0xd9,0xb5,0x6b,0x00,0x8d,0xbc,0x3c,0xf5,0xc4,0xba,0x57,0xc8,0x6d,0xfa,
0x62,0xfa,0xbe,0x93,0xa3,0x76,0x9a,0xad,0xa9,0x14,0x54,0x13,0x79,0x76,0x6a,0xd5,
0x7c,0x01,0xdb,0xd3,0xe9,0x11,0x3a,0x15,0x96,0x07,0xac,0xb7,0x71,0x63,0x4d,0x45,
0x0f,0x8b,0x22,0xfa,0xf7,0xcb,0x0a,0x94,0x25,0xb9,0x6d,0x05,0xd3,0x16,0x8a,0x55,
0xcf,0x13,0x1e,0xd9,0x8b,0x66,0x37,0x7a,0xce,0x01,0x95,0x67,0xa6,0x20,0xc4,0xb6,
0x6b,0x95,0xfd,0x2f,0xe1,0xd1,0xc3,0xe4,0x0f,0x2a,0xa7,0xb6,0x42,0x88,0x5a,0xbc,
0x4d,0xd5,0xd2,0xe5,0x77,0x0d,0x62,0x7f,0xe2,0xbc,0x66,0xdd,0x2a,0x7f,0x6c,0x63,
0x88,0x17,0x6c,0x77,0x87,0xbb,0x03,0xac,0x4a,0x51,0xa7,0x60,0x12,0x0f,0xba,0x40,
0xbe,0x68,0x6d,0xe1,0xd3,0xc8,0x36,0x7f,0x9e,0x54,0xec,0x38,0x2a,0xd9,0x2f,0x31,
0x05,0x15,0x70,0xc3,0x60,0x1e,0xb3,0x81,0x02,0x6b,0xe8,0x70,0x77,0x85,0xaa,0x8d,
0xf7,0xc5,0x24,0xb8,0xed,0xc2,0x56,0xf5,0xac,0x2e,0x74,0x07,0xe1,0x05,0x39,0xaf,
0x43,0xbd,0x76,0x86,0x7e,0x46,0x88,0xe9,0xde,0xb3,0x6f,0x26,0xfd,0xf0,0x52,0x03,
0xab,0xa8,0x02,0x0b,0x4d,0x62,0x31,0xfa,0x6d,0xd7,0x8d,0xe1,0xd6,0xba,0xba,0xa1,
0xce,0xaf,0x2b,0xb0,0x88,0x04,0xc6,0xb8,0x9e,0x5f,0xfd,0xcc,0x50,0xa8,0xfe,0x9f,
0x5e,0x51,0x62,0xeb,0xa6,0xcf,0xec,0x67,0xb7,0xde,0x4f,0x11,0x66,0x21,0xa6,0xa1,
0x78,0xf0,0x23,0xbc,0x5d,0x39,0xe7,0x1b,0x25,0x30,0xef,0xa5,0x2c,0x53,0x9c,0x35,
0x4a,0x1a,0x89,0x8f,0xe7,0x5a,0x7d,0xd5,0x96,0x5a,0x97,0x02,0x31,0x76,0xf5,0x9f,
0xb4,0x96,0xbd,0xf1,0xa6,0x60,0x40,0x2a,0x3f,0x0c,0x86,0x56,0x5a,0x79,0xa3,0xea,
0x3b,0x51,0x0b,0x7c,0x8b,0xf5,0x7e,0xf4,0x57,0x2a,0x6d,0x21,0x55,0x5e,0xac,0xae,
0x4b,0x76,0x79,0x69,0x1f,0xae,0xdc,0xbe,0x78,0xb1,0xc9,0xff,0xfe,0xa1,0x3d,0x2e,
0x94,0x1c,0x31,0xfd,0x76,0x02,0xb2,0x2d,0x2d,0xa7,0x69,0x2d,0x4a,0x37,0xbe,0xfe,
0x02,0xdb,0xea,0xa2,0x64,0x5b,0xa0,0x58,0x9f,0x9d,0x65,0x6b,0x50,0x11,0xc5,0x43,
0x50,0x7b
  };

  unsigned char dat[MAX_RSA_MODULUS_LEN];
  unsigned int dlen;
#if 0
  typedef struct {
    unsigned short int bits;                     /* length in bits of modulus */
    unsigned char modulus[MAX_RSA_MODULUS_LEN];  /* modulus */
    unsigned char exponent[MAX_RSA_MODULUS_LEN]; /* public exponent */
  } R_RSA_PUBLIC_KEY;
typedef struct {
  unsigned short int bits;                     /* length in bits of modulus */
  unsigned char modulus[MAX_RSA_MODULUS_LEN];  /* modulus */
  unsigned char publicExponent[MAX_RSA_MODULUS_LEN];     /* public exponent */
  unsigned char exponent[MAX_RSA_MODULUS_LEN]; /* private exponent */
  unsigned char prime[2][MAX_RSA_PRIME_LEN];   /* prime factors */
  unsigned char primeExponent[2][MAX_RSA_PRIME_LEN];     /* exponents for CRT */
  unsigned char coefficient[MAX_RSA_PRIME_LEN];          /* CRT coefficient */
} R_RSA_PRIVATE_KEY;
#endif
  R_RSA_PUBLIC_KEY _publicKey = {
      /*.bits = */1024,
      /*.modulus = */{  	0xb1,0x6a,0x65,0xe9,0x7a,0x63,0xd0,0x4f,0x01,0x54,0xeb,0x51,0x43,0x2c,
                            0xb8,0x12,0xe0,0x40,0x6e,0x56,0x8d,0x3f,0x6b,0x52,0xd9,0xdf,0x9a,0x86,0xdc,
                            0xdb,0xe0,0xf1,0x96,0x6b,0x46,0x99,0x33,0x28,0xb5,0x61,0x00,0x5c,0xc6,0x41,
                            0xd5,0x8f,0xaf,0x17,0x0d,0xd9,0x3c,0x9c,0xf9,0x7c,0xb5,0x49,0xae,0xa4,0x55,
                            0xad,0x99,0xab,0x96,0x5d,0xc5,0x6e,0x5d,0x7b,0x8d,0xf7,0xdb,0xc6,0xa5,0x00,
                            0x62,0xd4,0x91,0xfe,0x58,0x5b,0xa5,0xd0,0xf8,0x56,0xa0,0xfa,0x2b,0x09,0x78,
                            0x2a,0x42,0xe8,0x7a,0xf0,0x7c,0x7d,0xfc,0xc7,0xfb,0xc0,0xba,0xe2,0xfc,0xb2,
                            0x0c,0xd3,0xda,0xaa,0x77,0x88,0xdb,0xb9,0xfe,0x9f,0x7b,0xb0,0xad,0xa8,0x69,
                            0x77,0xae,0x61,0xbe,0x38,0x53,0x61,0x3e,0x47

      },
      /*.exponent = */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01},
  };    /* new RSA public key */
  R_RSA_PRIVATE_KEY _privateKey = {
      /*.bits = */1024,
      /*.modulus = */{    0xb1,0x6a,0x65,0xe9,0x7a,0x63,0xd0,0x4f,0x01,0x54,0xeb,0x51,0x43,0x2c,
                          0xb8,0x12,0xe0,0x40,0x6e,0x56,0x8d,0x3f,0x6b,0x52,0xd9,0xdf,0x9a,0x86,0xdc,
                          0xdb,0xe0,0xf1,0x96,0x6b,0x46,0x99,0x33,0x28,0xb5,0x61,0x00,0x5c,0xc6,0x41,
                          0xd5,0x8f,0xaf,0x17,0x0d,0xd9,0x3c,0x9c,0xf9,0x7c,0xb5,0x49,0xae,0xa4,0x55,
                          0xad,0x99,0xab,0x96,0x5d,0xc5,0x6e,0x5d,0x7b,0x8d,0xf7,0xdb,0xc6,0xa5,0x00,
                          0x62,0xd4,0x91,0xfe,0x58,0x5b,0xa5,0xd0,0xf8,0x56,0xa0,0xfa,0x2b,0x09,0x78,
                          0x2a,0x42,0xe8,0x7a,0xf0,0x7c,0x7d,0xfc,0xc7,0xfb,0xc0,0xba,0xe2,0xfc,0xb2,
                          0x0c,0xd3,0xda,0xaa,0x77,0x88,0xdb,0xb9,0xfe,0x9f,0x7b,0xb0,0xad,0xa8,0x69,
                          0x77,0xae,0x61,0xbe,0x38,0x53,0x61,0x3e,0x47
      },
      /*.publicExponent = */{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                             0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                             0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                             0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                             0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                             0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                             0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                             0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01},
      /*.exponent = */{    0x75,0x78,0x2e,0x6c,0x4e,0x06,0x42,0xc9,0xdc,0xe6,0xde,0x3c,0x5b,0x0f,0x03,
                           0xfe,0x33,0x8f,0x55,0xbf,0x67,0x1c,0xa3,0xb2,0x22,0xe2,0x43,0xcd,0xa1,0xf4,
                           0xd0,0x57,0x05,0xb2,0x97,0xf7,0x1e,0x01,0x89,0x3e,0xe5,0xdf,0x87,0xc1,0xd5,
                           0x66,0xa2,0x96,0xd0,0x2b,0x93,0x4f,0x98,0x7d,0x73,0x07,0x8b,0x63,0xf1,0xfa,
                           0xd4,0xf1,0xe0,0xc7,0xb0,0x9a,0xc3,0xfb,0x0b,0xcf,0xcd,0x3f,0x81,0x02,0xfe,
                           0x2a,0x35,0x23,0x9b,0x6a,0xbe,0x69,0xe5,0xaf,0x6d,0xe3,0x51,0x25,0x2a,0x9c,
                           0xc6,0xe7,0xad,0xf4,0x5b,0x22,0x27,0x49,0xe0,0x25,0x2a,0x61,0x92,0x3d,0xa8,
                           0x7b,0xbc,0x24,0xef,0x3d,0x27,0xff,0xc9,0xe5,0xb9,0x14,0x20,0x29,0x12,0x5b,
                           0xc0,0xc3,0x90,0x90,0xb9,0x51,0xf2,0xe9
                    },
      /*.prime = */{
          {    0xe7,0xab,0xff,0x5e,0xc9,0xc8,0xfd,0xe5,0x61,0x26,0x0a,0x98,0xb1,0xd6,
               0xa8,0xa6,0x03,0xde,0x3d,0x5b,0xfc,0x3d,0xb7,0x3e,0xba,0xd8,0x07,0xc0,0xa8,
               0x52,0xae,0xb2,0xf3,0xef,0x76,0x97,0x07,0x68,0x9d,0xa1,0xe7,0x25,0x72,0xa7,
               0x37,0x09,0xeb,0x06,0xb3,0x10,0xb3,0x08,0x18,0x35,0x1e,0xe4,0x2d,0xba,0x9e,
               0xec,0x07,0xa5,0xf9,0x1b
          },
          {    0xc4,0x0b,0xd6,0x60,0x4e,0x4a,0xfa,0x51,0xe8,0xee,0x85,0x28,0x6d,0xc7,
               0xfa,0xf3,0x56,0x52,0xde,0x82,0xa0,0x0c,0x27,0xc1,0x65,0x63,0x72,0xe8,0xe1,
               0x8c,0x4b,0x1e,0xdb,0xea,0x1c,0x31,0x0e,0x03,0xac,0x9b,0x0c,0x5b,0xa6,0x3b,
               0x44,0x1e,0x1e,0xfa,0x17,0x30,0xae,0x10,0x6d,0x35,0x4e,0xb0,0x70,0x70,0x5d,
               0xcd,0x61,0x0a,0xee,0x45
          },
      },
      /*.primeExponent = */{
          {    0xaa,0x5d,0x5f,0x84,0x13,0x1b,0x8d,0x2a,0x5b,0x50,0xa0,0x46,0x3d,0xb1,
               0x3f,0x80,0x26,0x24,0x0e,0x37,0x50,0xbd,0x09,0xbe,0x45,0xa4,0x8b,0xbe,0xef,
               0x89,0x2e,0x13,0x47,0x33,0x77,0xa0,0x04,0xc0,0xb7,0xfa,0xd1,0x82,0x46,0x58,
               0x15,0x2f,0x63,0xf8,0x1f,0x42,0x4e,0x85,0xcb,0x57,0x75,0x0a,0x13,0x5e,0xc3,
               0x73,0x8b,0x04,0x50,0xb5
          },
          {    0x6b,0x2e,0x65,0x97,0xe5,0x76,0x0c,0x80,0xf7,0xae,0x5f,0xd2,0x88,0xa2,0x8a,
               0xca,0xba,0xe9,0x37,0x89,0x86,0xe2,0xde,0x61,0x57,0x83,0x15,0x71,0xc8,0xce,
               0x20,0xcb,0xd0,0x43,0xa0,0x02,0x19,0xbd,0x5c,0x82,0xb0,0x30,0xf3,0x22,0xf7,
               0xcc,0xd7,0xf6,0xb6,0xf3,0x00,0x57,0x2e,0xbd,0xb4,0x35,0xb6,0x63,0x58,0x85,
               0x4e,0x86,0xe1,0x59
          },
      },
      /*.coefficient = */{    0xdc,0xe0,0x36,0x05,0x78,0xc0,0xb7,0x54,0x06,0x7d,0x0e,0xc4,0x41,0x4a,
                              0x56,0x19,0x2a,0xe5,0xbd,0x63,0xb3,0x95,0x7c,0x39,0x4e,0xa0,0x6f,0xa9,0xed,
                              0xcc,0x36,0x30,0x27,0x42,0x79,0x6f,0x15,0x34,0xdb,0x2a,0xdc,0xd4,0xf2,0x58,
                              0xe7,0x5d,0x8a,0x40,0x3b,0x93,0x9a,0x8c,0x37,0x2c,0xe0,0x00,0x0b,0xf6,0x87,
                              0x6c,0x8c,0xc4,0xf9,0x70
      },
  };  /* new RSA private key */
//  MD5_CTX ctx;
  unsigned char md5[117]="1234567890ABCDE";
//  MD5Init(&ctx);
//  MD5Update(&ctx,id,strlen(id));
//  MD5Update(&ctx,sn,strlen(sn));
//  MD5Final(md5, &ctx);
  int status = 0;
#if 1
  dlen = sizeof (dat);
  status = RSAPrivateEncrypt(dat,&dlen,md5,sizeof(md5), &_privateKey);
  printf("after Encrypt data len : %d status:%d\n", dlen, status);
  if(ID_OK!=status)
  {
      printf("Encrypt status : 0x%02X\n", status);
  }
  dlen = sizeof (dat);
  status = RSAPublicDecrypt(dat,&dlen,dat,dlen,&_publicKey);
  printf("after Decrypt data len : %d status:%d\n", dlen, status);
  if(ID_OK!=status)
  {
      printf("Decrypt status : 0x%02X\n", status);
  }
#else
  RSAPrivateEncrypt(dat,&dlen,md5,sizeof(md5), (R_RSA_PRIVATE_KEY*)privatekey);
  RSAPublicDecrypt(dat,&dlen,dat,dlen,(R_RSA_PUBLIC_KEY*)publickey);
#endif
  fflush(stdout);
  //return 0;
}
#endif

#endif


void rsa_main(void)
{
    unsigned char dat[4096];
    unsigned int dlen;
    rsa_int();
#if 1
    unsigned char md5[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890"
                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890"
                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890"
                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890"
                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890";
#else
    unsigned char md5[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890";;
#endif
    dlen = sizeof (dat);
    printf("Encrypt data : %s\n", md5);
    dlen = rsa_encrypt(dat, sizeof (dat), md5, sizeof(md5));
    printf("after Encrypt data len : %d\n\n", dlen);
    dlen = rsa_decrypt(dat, sizeof (dat), dat, dlen);
    printf("after Decrypt data len : %d\n", dlen);
    dat[dlen] = '\0';
    printf("Decrypt data : %s\n", dat);
    fflush(stdout);
    //test1();
}



